# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time      :2022/7/26 0026 1:41
# @Author    :jiaxuesong

#实现公共方法维护

# 导包
from appium_test.common.driver import *
from appium import webdriver
from appium_test.common.log import *
# 创建公共方法类
class Public(object):
    #创建初始化方法
    def __init__(self, driver):
        self.driver = driver

    #创建对外调用屏幕操作的实例化方法
    # 定义一个方法获取屏幕大小
    def get_size(self):
        x = self.driver.get_window_size()['width']
        y = self.driver.get_window_size()['height']
        logger.info('获取屏幕大小函数')
        return (x, y)

    # 定义向上滑动方法
    def swipeUp(self):
        size = self.get_size()
        x1 = size[0] * 0.5
        y1 = size[1] * 0.75
        y2 = size[1] * 0.25
        self.driver.swipe(x1, y1, x1, y2)
        logger.info('向上滑动成功')

    # 定义一个向下滑动
    def swipeDown(self):
        size = self.get_size()
        x1 = size[0] * 0.5
        y1 = size[1] * 0.25
        y2 = size[1] * 0.75
        self.driver.swipe(x1, y1. x1. y2)
        logger.info('向下滑动成功')

    # 定义一个想左滑动方法
    def swipeLeft(self):
        size = self.get_size()
        x1 = size[0] * 0.75
        x2 = size[0] * 0.25
        y1 = size[1] * 0.5
        self.driver.swipe(x1, y1, x2, y1)
        logger.info('向左滑动成功')

    # 定义一个向右滑动方法
    def swipeRight(self):
        size = self.get_size()
        x1 = size[0] * 0.25
        x2 = size[0] * 0.75
        y1 = size[1] * 0.5
        self.driver.swipe(x1, y1, x2, y1)
        logger.info('向右滑动成功')

if __name__ == '__main__':
    driver = Driver().startUp()
    p = Public(driver)
    p.swipeLeft()